package com.sx.service.impl;

import com.sx.dao.PromotionSpaceMapper;
import com.sx.domain.PromotionSpace;
import com.sx.service.PromotionSpaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.UUID;


@Service
public class PromotionSpaceServiceImpl implements PromotionSpaceService {
    @Autowired
     private PromotionSpaceMapper promotionSpaceMapper;

    @Override
    public List<PromotionSpace> findAllPromotionSpace() {
        List<PromotionSpace> allPromotionSpace = promotionSpaceMapper.findAllPromotionSpace();
        return allPromotionSpace;

    }
    //添加广告位
    @Override
    public void savePromotionSpace(PromotionSpace promotionSpace) {
        //封装数据
        promotionSpace.setSpaceKey(UUID.randomUUID().toString());
        Date date = new Date();
        promotionSpace.setCreateTime(date);
        promotionSpace.setUpdateTime(date);
        promotionSpace.setIsDel(0);
        promotionSpaceMapper.savePromotionSpace(promotionSpace);
    }

    @Override
    public void updatePromotionSpace(PromotionSpace promotionSpace) {

        Date date = new Date();
        promotionSpace.setUpdateTime(date);

        promotionSpaceMapper.updatePromotionSpace(promotionSpace);
    }

    @Override
    public PromotionSpace findPromotionSpaceId(int id) {
        PromotionSpace promotionSpaceId = promotionSpaceMapper.findPromotionSpaceId(id);
        return promotionSpaceId;
    }


}
